public class Exercise7 {
    public int[] productExceptSelf(int[] nums) {
        int n = nums.length;
        int[] newNums = new int[n];
        for(int i = 0;i < n;i++) {
            int sum = 1;
            for(int j = 0;j < n;j++) {
                if(i != j) {
                    sum = sum * nums[j];
                }
            }
            newNums[i] = sum;
        }
        return newNums;
    }
}
